use vbpaper_2019version.dta , clear 
	
********************************************************************************
************ Figure 1: Ethnic targeting by country/party system ****************
********************************************************************************
preserve 

use partysystems_DALP.dta , clear 

twoway (scatter ethnic_targeting b15 if region_LA ==0, mlabel(country) mlabsize(tiny) mlabcolor(gs5) msize(small) mcolor(gs5) ///
xline(11.96652) yline(.2468206)) (scatter ethnic_targeting b15 if region_LA == 1, mlabel(country) ///
mlabsize(tiny) mlabcolor(gs0) msize(small) mcolor(gs0) msymbol(t)) , ///
title(Ethnic Targeting by Party System and Patronage, ring(4) position(6) justification(center)) ///
xtitle(Clientelistic Effort, size(medsmall)) legend(label(1 Outside LA) label(2 Latin America) size(small) nobox ///
region(lstyle(none))) ytitle(Targeting Ethnic Groups, size(medsmall)) graphregion(c(gs16)) name(ethnic_patronage, replace) ///
caption("The figure plots the average effort that political parties make to attract specific ethnic groups with targeted inducements" ///
`"(B8_3) by the total level of clientelistic effort in the party system (B15). The figure shows that Latin American party"' ///
`"systems (triangles) are highly clientelistic, but specific ethnic targeting is limited. The horizontal line represents the global"' ///
`"average of ethnic targeting. The vertical line represents the global average of clientelistic effort. Source: DALP (2014)"' , size(vsmall) ring(10))

restore 	

********************************************************************************
************ Figure 2: Logistic Regression of vote buy on  **********************
************       skin color, pooled nested model 	      **********************
********************************************************************************

melogit votebuy i.color_category_region female age urban colori ///
if minority_country == 1 & sample == 1 || country_round: , intpoints(10)

margins , at (color_category_region = (1 2 3 4 5 6)) predict(mu fixedonly) post saving(light_simple, replace)

test [1._at] = [2._at] = [3._at] = [4._at] = [5._at] = [6._at] , mtest(b)

melogit votebuy i.color_category_region wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (color_category_region = (1 2 3 4 5 6)) predict(mu fixedonly) post saving(light_full, replace)

combomarginsplot light_simple light_full , name(nestedmodel, replace) 	///
labels("Simple" "Full", labsize(small)) graphregion(c(gs16))  ///
legend(size(small) nobox region(lstyle(none))) ///
plot1opts(lcolor(black) mcolor(black)) ci1opts(lcolor(black)) ///
plot2opts(lcolor(black) mcolor(black) lpattern(dash)) ci2opts(lcolor(black)) ///
title("Figure 2: Predicted Probability of Client by Skin Color," "Nested Models", ring(3) position(6) justification(center)) ///
yscale(range(0.05(0.05)0.25)) ytitle("Pr(Client)") xtitle("Standardized Color") ///
caption("The figure plots the predicted probabilty of Client at six levels of Skin Color from nested logit models (simple-solid, full-dashed) for the pooled sample." ///
`"95 percent confidence intervals reported. Models include country-round fixed effects. Covariates are at observed values. Source: LAPOP 2010-2014"' ///
, size(vsmall) ring(6) span)

********************************************************************************
************* Figure 3: Marginal Effect by Clien Efficiency ********************
********************************************************************************

melogit votebuy light med_light med_dark dark verydark  female age urban colori ///
if minority_country == 1 & (country_2 == 1 | country_8 == 1 | country_10 == 1 | country_15 == 1 | country_18 == 1) || country_round: , intpoints(10)
	
	margins , dydx(dark) predict(mu fixedonly) saving(dark1_efficient, replace)

melogit votebuy light med_light med_dark dark verydark  female age urban colori ///
if minority_country == 1 & (country_2 == 1 | country_8 == 1 | country_10 == 1 | country_15 == 1 | country_18 == 1) || country_round: , intpoints(10)

	margins , dydx(verydark) predict(mu fixedonly) saving(verydark1_efficient, replace)
	
melogit votebuy light med_light med_dark dark verydark wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori ///
if minority_country == 1 & (country_2 == 1 | country_8 == 1 | country_10 == 1 | country_15 == 1 | country_18 == 1) || country_round: , intpoints(10)
	
	margins , dydx(dark) predict(mu fixedonly) saving(dark2_efficient, replace) //  

melogit votebuy light med_light med_dark dark verydark wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori ///
if minority_country == 1 & (country_2 == 1 | country_8 == 1 | country_10 == 1 | country_15 == 1 | country_18 == 1) || country_round: , intpoints(10)
	
	margins , dydx(verydark) predict(mu fixedonly) saving(verydark2_efficient, replace) //  
	
	combomarginsplot dark1_efficient verydark1_efficient dark2_efficient verydark2_efficient, ///
	labels("Simple: Dark" "Simple: Very Dark" "Full: Dark" "Full: Very Dark", labsize(small))  recast(scatter) name(efficient, replace) ///
	graphregion(c(gs16)) title(High Clientelistic Efficiency, justification(center)) ///
	yscale(range(-0.05(0.05)0.15)) ytitle(Avg. Marginal Effect on Client) xtitle(" ")

melogit votebuy light med_light med_dark dark verydark  female age urban colori ///
if minority_country == 1 & (country_6 == 1 | country_7 == 1 | country_9 == 1 | country_1 == 1 | country_11 == 1 | country_16 == 1) || country_round: , intpoints(10)
	
	margins , dydx(dark) predict(mu fixedonly) saving(dark1_notefficient, replace)

melogit votebuy light med_light med_dark dark verydark  female age urban colori ///
if minority_country == 1 & (country_6 == 1 | country_7 == 1 | country_9 == 1 | country_1 == 1 | country_11 == 1 | country_16 == 1) || country_round: , intpoints(10)
	
	margins , dydx(verydark) predict(mu fixedonly) saving(verydark1_notefficient, replace)

melogit votebuy light med_light med_dark dark verydark wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori ///
if minority_country == 1 & (country_6 == 1 | country_7 == 1 | country_9 == 1 | country_1 == 1 | country_11 == 1 | country_16 == 1) || country_round: , intpoints(10)

	margins , dydx(dark) predict(mu fixedonly) saving(dark2_notefficient, replace) //  

melogit votebuy light med_light med_dark dark verydark wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori ///
if minority_country == 1 & (country_6 == 1 | country_7 == 1 | country_9 == 1 | country_1 == 1 | country_11 == 1 | country_16 == 1) || country_round: , intpoints(10)

	margins , dydx(verydark) predict(mu fixedonly) saving(verydark2_notefficient, replace) //  

	combomarginsplot dark1_notefficient verydark1_notefficient dark2_notefficient verydark2_notefficient, ///
	labels("Simple: Dark" "Simple: Very Dark" "Full: Dark" "Full: Very Dark", labsize(small)) recast(scatter) ///
	name(notefficient, replace) graphregion(c(gs16)) title(Low Clientelistic Efficiency, justification(center)) ///
	yscale(range(-0.05(0.05)0.15)) ytitle(Avg. Marginal Effect on Client) xtitle(" ")

graph combine efficient notefficient , ycommon name(fig3, replace) ///
title("Figure 3: Avg. Marginal Effect of Skin Color on Client by Clientelistic" "Efficiency" , ring(3) ///
position(6) justification(center) size(medlarge)) graphregion(c(gs16)) ///
caption("The figure plots the average marginal effects of Dark and Very Dark on Client from nested logit models in efficient (left) and less efficient (right)" ///
`"patronage systems. 95 percent confidence intervals reported. Models include country-round fixed effects. Covariates are at observed values."' ///
`"Source: LAPOP 2010-2014"', size(vsmall) ring(6))

********************************************************************************
************ Figure 4: Skin Color & black and Indigenous PPs *******************
********************************************************************************

melogit votebuy i.color_category_region i.etid_new wealth_quintile_richtopoor partisan ///
civic2 pol_interest participation_index i_trust voted registered ed female age urban ///
colori i.year if country_9 == 1 || upm: , intpoints(10)
	margins ,  at (color_category_region = (3 4 5 6) etid_new = (3 4)) ///	 
	predict(mu fixedonly) post
	
		test [1._at] = [2._at]													// differences at all levels of skin color comparison significant 
		test [3._at] = [4._at]
		test [5._at] = [6._at]
		test [7._at] = [8._at]
		
	marginsplot, name(indy_color, replace) title("Figure 4: Predicted Probability of Client by Skin Color for Indigenous" ///
	"and Black Voters in Ecuador", ring(3) position(6) justification(center) size(medlarge)) ///
	graphregion(c(gs16)) ytitle("") xtitle("Skin Color") plot1opts(lpattern(dash) lcolor(gs5) mcolor(gs5)) ///
	plot2opts(lpattern(solid) lcolor(gs0) mcolor(gs0)) xlab(3 "Med Light" 4 "Med Dark" 5 "Dark" 6 "Very Dark", labsize(small)) noci ///
	legend(label(3 "Indigenous" 4 "Black") size(small) nobox region(lstyle(none))) ///
	caption("The figure plots the predicted probabilities of Client as a function of skin tone for self-identified indigenous and black respondents. Models include" ///
	`"country-round fixed effects. All covariates are held at their observed values."' ///
	`"Source: LAPOP 2010 and 2014"' , size(vsmall) ring(6) span)

********************************************************************************
******************** Figure 4: AMCEs full sample *******************************
********************************************************************************

preserve

use conjointanalysis.dta, clear 

reg vbprefer i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(amce_task1, replace) graphregion(c(gs16)) title("Vote buying" "Choice Task") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" ///
4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" 1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" ///
2.newvote = "maybe vote" 3.newvote = "yes vote" 0.party_match = "no party match" 1.party_match = "party match") ///
xtitle("Effect on Pr(Choice)")


reg vb i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(vbamce_task1, replace) graphregion(c(gs16)) title("Vote buying" "Rating Task") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match") xtitle("Effect on Rating")

graph combine amce_task1 vbamce_task1 , graphregion(c(gs16)) title("Figure 4: AMCEs Choice and Rating Tasks (full sample)" , ring(3) ///
position(6) justification(center) size(medlarge)) /// 
caption("The figure presents the AMCEs of fictional voter traits on the choice and rating tasks (Task 1 only). 95 percent" ///
`"confidence intervals reported."', size(vsmall) ring(6))

restore 

********************************************************************************
***************** Figure 5: AMCEs Campaign Workers *****************************
********************************************************************************

preserve

use conjointanalysis.dta, clear 

reg vbprefer i.lighttodark4 i.newjob i.newvote i.party_match if task == 1 & campaigner == 1  
coefplot, base levels(95) drop(_cons) xline(0) name(amce_task1_camp, replace) graphregion(c(gs16)) title("Vote buying" "Choice Task") ///
coeflabels(1.lighttodark4 = "light" 2.lighttodark4 = "medium" 3.lighttodark4 = "dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match") xtitle("Effect on Pr(Choice)")

reg vb i.lighttodark4 i.newjob i.newvote i.party_match if task == 1 & campaigner == 1 
coefplot, base levels(95) drop(_cons) xline(0) name(vbamce_task1_camp, replace) graphregion(c(gs16)) title("Vote buying" "Rating Task") ///
coeflabels(1.lighttodark4 = "light" 2.lighttodark4 = "medium" 3.lighttodark4 = "dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match") xtitle("Effect on Rating")

graph combine amce_task1_camp vbamce_task1_camp, graphregion(c(gs16)) title("Figure 5: AMCEs Choice and Rating Tasks (campaign workers)" , ring(3) ///
position(6) justification(center) size(medlarge)) /// 
caption("The figure presents the AMCEs of fictional voter traits on the choice and rating tasks (Task 1 only). 95 percent" ///
`"confidence intervals reported."', size(vsmall) ring(6))
name(campcombined, replace)

restore


********************************************************************************
********************************************************************************
********************************************************************************
************************* FOR APPENDICES ***************************************
********************************************************************************
********************************************************************************
********************************************************************************

********************************************************************************
*************** Appendix 1: Table 1.1-Descriptive Statistics *******************
********************************************************************************
 
preserve 		

tab year, gen(y_)																

keep votebuy verylight light med_light med_dark dark verydark wealth_quintile_richtopoor /// 
partisan civic2 pol_interest participation_index i_trust voted registered ed female ///
age urban colori country_round y_1 y_2 y_3 sample minority_country

keep if minority_country == 1 & sample == 1

drop sample minority_country

outreg2 using summary_vbpaperJul2019.doc, sum(log) replace 

restore

********************************************************************************
************ Appendix 1: Table 1.2 - skin color, pooled nested model  **********
********************************************************************************

melogit votebuy i.color_category_region female age urban colori if minority_country == 1 & sample == 1 || country_round: , intpoints(10)		
	
	estimates store simple1
	outreg2 using la_melogit_skincolor_Jul3.doc, replace 							

melogit votebuy i.color_category_region wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)
	
	estimates store full1
	outreg2 using la_melogit_skincolor_Jul3.doc 							
	
********************************************************************************
******************** Appendix 1: Country Models & Predicted Probabilities ******
********************************************************************************

foreach i in country_1 country_2 country_6 country_7 country_8 country_9 country_10 country_11 country_15 country_16 country_18 { // Colombia approaches sig but not sig if I switch to color_cat3 so I think the conservative approach is to stick with color_cat2 
	display "********* `i' ****************" 
	
	melogit votebuy color_category_region female age urban colori i.year if `i' == 1 || upm:
	
	outreg2 using `i'_model_jul3.doc, replace 
	
	melogit votebuy i.color_category_region female age urban colori i.year if `i' == 1|| upm:
	
	outreg2 using `i'_model_jul3.doc 

	melogit votebuy i.color_category_region wealth_quintile_richtopoor				///
	partisan civic2 pol_interest participation_index i_trust ///
	voted registered ed female age urban colori i.year ///
	if `i' == 1 || upm:

	outreg2 using `i'_model_jul3.doc 
	
	melogit votebuy color_category_region wealth_quintile_richtopoor				///
	partisan civic2 pol_interest participation_index i_trust ///
	voted registered ed female age urban colori i.year ///
	if `i' == 1 || upm:

	outreg2 using `i'_model_jul3.doc 
	
}

preserve 

rename country_1 Mexico
rename country_2 Guatemala
rename country_6 Costa_Rica
rename country_7 Panama
rename country_8 Colombia
rename country_9 Ecuador 
rename country_10 Bolivia
rename country_11 Peru
rename country_15 Brazil 
rename country_16 Venezuela
rename country_18 Dom_Republic

foreach i in Mexico Guatemala Peru Bolivia Costa_Rica { 

melogit votebuy i.color_category_region female age urban colori i.year if `i' == 1 || upm:
	margins, at (color_category_region = (1 2 3 4 5)) predict(mu fixedonly) post saving(`i'_simple, replace)

melogit votebuy i.color_category_region wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori i.year ///
if `i' == 1 || upm:
	margins, at (color_category_region = (1 2 3 4 5)) predict(mu fixedonly) post saving(`i'_full, replace) 

combomarginsplot `i'_simple `i'_full, name(`i'_nestedmodel, replace) noci	///
labels("Simple" "Full", labsize(small)) graphregion(c(gs16))  ///
legend(off) plot1opts(lcolor(black) mcolor(black))  ///
plot2opts(lcolor(black) mcolor(black) lpattern(dash)) ///
title("`i'", justification(center)) ytitle("") xtitle("") 

}

foreach i in Dom_Republic Venezuela Brazil Ecuador Colombia Panama { 

melogit votebuy i.color_category_region female age urban colori i.year if `i' == 1 || upm:
	margins, at (color_category_region = (1 2 3 4 5 6)) predict(mu fixedonly) post saving(`i'_simple, replace)

melogit votebuy i.color_category_region wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori i.year ///
if `i' == 1 || upm:
	margins, at (color_category_region = (1 2 3 4 5 6)) predict(mu fixedonly) post saving(`i'_full, replace) 

combomarginsplot `i'_simple `i'_full, name(`i'_nestedmodel, replace) noci	///
labels("Simple" "Full", labsize(small)) graphregion(c(gs16))  ///
legend(off) plot1opts(lcolor(black) mcolor(black))  ///
plot2opts(lcolor(black) mcolor(black) lpattern(dash))  ///
title("`i'", justification(center)) ytitle("") xtitle("") 

}

graph combine Mexico_nestedmodel Panama_nestedmodel Ecuador_nestedmodel Bolivia_nestedmodel ///
Peru_nestedmodel Dom_Republic_nestedmodel Brazil_nestedmodel ///
Venezuela_nestedmodel Guatemala_nestedmodel Costa_Rica_nestedmodel Colombia_nestedmodel , ///
name(appfig_none, replace) title("Appendix Figure 1.1: Predicted Probabilities of Client on Skin Color" "by Country" ,  ///
justification(center) size(medlarge)) graphregion(c(gs16)) 

restore 

********************************************************************************
************ Appendix 1: Table  1.3 & 1.4- Oaxaca-Blinder Analysis *************
********************************************************************************

gen dark_verydark = . 
	replace dark_verydark = 1 if color_category_region == 5 | color_category_region == 6
	replace dark_verydark = 0 if color_category_region < 5

oaxaca votebuy wealth_quintile_richtopoor partisan requester_local civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori if pais == 7 , by(dark_verydark) swap detail pooled svy
		
outreg2 using oaxaca_panama_jul3.doc, replace 

oaxaca votebuy wealth_quintile_richtopoor partisan requester_local civic2 pol_interest participation_index i_trust ///
voted registered ed female age urban colori if pais == 15 , by(dark_i) swap detail pooled svy 

outreg2 using oaxaca_brazil_jul3.doc, replace 

********************************************************************************
************ Appendix 1: Figure 1.2- skin color identification *****************
********************************************************************************

preserve

keep if minority_country == 1

collapse white mestizo indigenous black other [pw=wt], by(color_category_region2)
	
graph twoway (line white color_category_region2, lcolor(black) lpattern(solid) legend(label(1 "White") label(2 "Mixed Race") label(3 "Indigenous") label(4 "Black") label(5 "Other"))) (line mestizo color_category_region2, lcolor(black) lpattern(dot)) ///
(line indigenous color_category_region2, lcolor(blue) lpattern(dash)) (line black color_category_region2, lcolor(red) lpattern(longdash)) (line other color_category_region2, lcolor(black) lpattern(longdash)), name(Colorbyrace, replace) ///
title("Appendix Figure 1.1: % of Racial Identification at Standardized Levels" "of Skin Color") graphregion(c(gs16) lcolor(black)) ytitle("% of racial group in color category") xtitle("Skin Color (standardized within country)") ///
xlab(1 "Very Light" 2 "Light" 3 "Med Light" 4 "Med Dark" 5 "Dark" 6 "Very Dark")

restore 

********************************************************************************
************ Appendix 1: Figure 1.3- bribes ok interaction *********************
********************************************************************************

melogit votebuy i.color_category_region##i.bribes_ok wealth_quintile_richtopoor ///
partisan civic2 pol_interest participation_index i_trust voted 					///
registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10)

margins, at(color_category_region=(1 (1) 6) bribes_ok=(0 1) ) atmeans predict(mu fixedonly)

marginsplot, name(appfig_bias, replace) plot1opts(lcolor(black) mcolor(black))  ///
plot2opts(lcolor(black) mcolor(black) lpattern(dash)) ci1opts(lcolor(black))  ///
ci2opts(lcolor(black)) graphregion(c(gs16)) ytitle("Pr(Client)") xtitle("Standardized Color") ///
xlab(1 "V. Light" 2 "Light" 3 "Med. Light" 4 "Med. Dark" 5 "Dark" 6 "V. Dark") /// 
title("Appendix Figure 1.3: Predicted Prob. of Client by Color-Bribes_OK" "Interaction") 


********************************************************************************
************ Appendix 1: Figure 1.4- Covariate PP plots ************************
********************************************************************************

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (i_trust = (0 3)) predict(mu fixedonly) post saving(trust, replace)

marginsplot , noci recast(line) name(trust, replace) ///
xlab(0 "Min" 3 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Trust", justification(center)) xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (wealth_quintile_richtopoor = (1 5)) predict(mu fixedonly) post saving(wealth, replace)

marginsplot , noci recast(line) name(wealth, replace) ///
xlab(1 "Min" 5 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Wealth", justification(center)) xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (partisan = (0 1)) predict(mu fixedonly) post saving(partisan, replace)

marginsplot , noci recast(line) name(partisan, replace) ///
xlab(0 "Min" 1 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Partisan", justification(center)) xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (civic2 = (0 4)) predict(mu fixedonly) post saving(civic, replace)

marginsplot , noci recast(line) name(civic, replace) ///
xlab(0 "Min" 4 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Civic", justification(center))  xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (participation_index = (0 3)) predict(mu fixedonly) post saving(participation, replace)

marginsplot , noci recast(line) name(participation, replace) ///
xlab(0 "Min" 3 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Participation", justification(center))  xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (pol_interest = (0 3)) predict(mu fixedonly) post saving(interest, replace)

marginsplot , noci recast(line) name(pol_interest, replace) ///
xlab(0 "Min" 3 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Political Interest", justification(center))  xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (voted = (0 1)) predict(mu fixedonly) post saving(voted, replace)

marginsplot , noci recast(line) name(voted, replace) ///
xlab(0 "Min" 1 "Max", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Voted", justification(center))  xtitle("") ytitle("")

melogit votebuy i.color_category_region i.wealth_quintile_richtopoor				///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

margins , at (female = (0 1)) predict(mu fixedonly) post saving(female, replace)

marginsplot , noci recast(line) name(Gender, replace) ///
xlab(0 "Man" 1 "Woman", labsize(small)) graphregion(c(gs16))  ///
plot1opts(lcolor(black) mcolor(black)) ///
title("Gender", justification(center))  xtitle("") ytitle("")

graph combine wealth partisan civic participation pol_interest trust voted Gender, rows(2) ycommon ///
graphregion(c(gs16)) title("Appendix Figure 1.4: Predicted Probabilities of Main Model Covariates", justification(center) size(medlarge)) ///
caption("The figure plots the predicted probabilties of key covariates in the main model for the pooled sample. Predicted probabilities were calculated at the" ///
`"minimum and maximum values of each covariate. These predictions should be compared to the predicted probabilities for Skin Color (Figure 2"' ///
`"of the manuscript). Models include country-round fixed effects. Covariates are at observed values. Source: LAPOP 2010-2014"' ///
, size(vsmall) ring(6) span)

********************************************************************************
************ Appendix 2: Table 2.1- trait randomization worked across tasks ****
********************************************************************************
preserve

use conjointanalysis.dta, clear 

drop if profile == "_frequency"
drop if profile == "_matters"

gen r_l = .
	replace r_l = 1 if profile == "1_2" | profile == "2_2" | profile == "3_2" | profile == "4_2" | profile == "5_2" | profile == "6_2"
	replace r_l = 0 if profile == "1_1" | profile == "2_1" | profile == "3_1" | profile == "4_1" | profile == "5_1" | profile == "6_1"

bysort task: tab lighttodark3 newjob if vbprefer !=.

restore

********************************************************************************
************ Appendix 2: Table 2.2- trait Campaign worker characteristics ******
********************************************************************************

preserve 

use conjointdescriptives_wide.dta , clear 

mean gender age edu employed salario citizen cedula inscrito PRD PP CD Pan MOL FAD, over(campaigner)

estimates store comparison_subsample

restore

********************************************************************************
************ Appendix 2: Table 2.3- Fictional Voter Photos  ********************
********************************************************************************

********************************************************************************
************ Appendix 2: Table 2.4- Choice Task on Color and Task interaction***
********************************************************************************

preserve 

use conjointanalysis.dta, clear 

reg vbprefer i.lighttodark3##i.task , cluster(responseid)

restore 

********************************************************************************
************ Appendix 2: Table 2.5- Black Round 1 interaction ******************
********************************************************************************

preserve 

use conjointanalysis.dta, clear 

gen profile2 = . 																
	replace profile2 = 1 if profile == "1_1"
	replace profile2 = 2 if profile == "1_2"
	replace profile2 = 3 if profile == "2_1"
	replace profile2 = 4 if profile == "2_2"
	replace profile2 = 5 if profile == "3_1"
	replace profile2 = 6 if profile == "3_2"
	replace profile2 = 7 if profile == "4_1"
	replace profile2 = 8 if profile == "4_2"
	replace profile2 = 9 if profile == "5_1"
	replace profile2 = 10 if profile == "5_2"
	replace profile2 = 11 if profile == "6_1"
	replace profile2 = 12 if profile == "6_2"
	
gen b1 = . 
	replace b1 = 1 if profile == "1_1" & lighttodark3 >= 4

gen b2 = . 
	replace b2 = 1 if profile == "1_2" & lighttodark3 >= 4
	
gen b1_1 = .
forval i = 1/`=_N' {
	su b2 if responseid == responseid[`i'] , meanonly
	replace b1_1 = r(min) in `i'
	}
gen b1_2 = .
forval i = 1/`=_N' {
	su b1 if responseid == responseid[`i'] , meanonly
	replace b1_2 = r(min) in `i'
	}

gen black_round1 =. 
	replace black_round1 = 1 if b1_1 ==1 & b1_2 == 1
	replace black_round1 = 0 if black_round1 == . 
	
reg vb i.lighttodark3##i.black_round1 i.newjob i.newvote i.party_match i.task , cluster(responseid)

restore 

********************************************************************************
************ Appendix 2: Fig 2.1- Tasks 1-6 for full sample ********************
********************************************************************************

preserve

use conjointanalysis.dta, clear 

reg vbprefer i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task1, replace) graphregion(c(gs16)) title("Choice Task" "Task 1") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

reg vbprefer i.lighttodark3 i.newjob i.newvote i.party_match if task == 3 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task3, replace) graphregion(c(gs16)) title("Choice Task" "Task 3") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

reg vbprefer i.lighttodark3 i.newjob i.newvote i.party_match if task == 6, cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task6, replace) graphregion(c(gs16)) title("Choice Task" "Task 6") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

reg vb i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task1_rate, replace) graphregion(c(gs16)) title("Rating Task" "Task 1") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

reg vb i.lighttodark3 i.newjob i.newvote i.party_match if task == 3 , cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task3_rate, replace) graphregion(c(gs16)) title("Rating Task" "Task 3") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

reg vb i.lighttodark3 i.newjob i.newvote i.party_match if task == 6, cluster(responseid)
coefplot, base levels(95) drop(_cons) xline(0) name(task6_rate, replace) graphregion(c(gs16)) title("Rating Task" "Task 6") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match")

graph combine task1 task3 task6 task1_rate task3_rate task6_rate, graphregion(c(gs16)) name(campcombined, replace)

restore

********************************************************************************
************ Appendix 2: Fig 2.2- Disaggregated Color and Gender ***************
********************************************************************************

preserve

use use conjointanalysis.dta, clear 

reg vbprefer i.lighttodark i.newjob i.newvote i.party_match if task == 1 , cluster(responseid)

restore


********************************************************************************
********************** Extra Tests and Models **********************************
********************************************************************************


*************** Mean VB reporting by country 

svy: tab pais votebuy if year==2010 | year==2014, row missing // showing the reports and missingness of vote buying by country 
	svy: tab pais votebuy if year==2014 & pais==4, row  missing // replace Honduras for just 2014 because question not asked in 2010 
	svy: tab pais votebuy if pais==2 | pais == 17 | pais == 21 | pais == 8 | pais == 12, row  missing // replace Guatemala, Argentina, DR, Col, and Paraguay incorporating 2012 data  


************** Full vote buy regression with requester, civic original, q10, personality/reliability,
************** reliability, partisan_index, & persuasion frequency						 

melogit votebuy i.color_category_region wealth_quintile_richtopoor		///
partisan requester_local civic2 pol_interest participation_index i_trust 	///
voted registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10)				// with requester_local
	
	*outreg2 using vbextramodelsWP2019.doc, replace
	
	
melogit votebuy i.color_category_region wealth_quintile_richtopoor 		///
partisan requester_local civic pol_interest participation_index i_trust 	///
voted registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10)				// with full civic variable 
	
	*outreg2 using vbextramodelsWP2019.doc
	
melogit votebuy i.color_category_region q10 								///
partisan civic2 pol_interest participation_index i_trust 	///
voted registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10) 				// with q10 instead of household wealth

	*outreg2 using vbextramodelsWP2019.doc

melogit votebuy i.color_category_region wealth_quintile_richtopoor		///
partisan reliability civic2 pol_interest participation_index i_trust 	///
voted registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10)				// with reliability 

	*outreg2 using vbextramodelsWP2019.doc

melogit votebuy i.color_category_region wealth_quintile_richtopoor		///
partisan partisan_index persuasion_freq civic2 pol_interest participation_index i_trust 	///
voted registered ed female age urban colori if minority_country == 1 || country_round: , intpoints(10)				// with partisan_index, persuasion_freq  

	*outreg2 using vbextramodelsWP2019.doc


************** Appendix 1: Table 1.2-vote buy variable recoded to be the original 
************** 3 level outcome variable 

meologit votebuy_times i.color_category_region wealth_quintile_richtopoor		///
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)
	
	outreg2 using meologit_votebuytimes.doc, replace 
	

************ Appendix 1: Figure 1.2- skin color id interaction 

melogit votebuy i.color_category_region##i.etid_new wealth_quintile_richtopoor /// 
partisan civic2 pol_interest participation_index i_trust voted registered ed female ///
age urban colori if minority_country == 1 || country_round: , intpoints(10)
	margins ,  at (color_category_region = (3 4 5 6) etid_new = (3 4) ///	as skin color varies with wealth 
	(mean) colori ed age i_trust pol_interest participation_index civic urban = 1 voted = 1 partisan = 1 registered = 1 ///
	female = 1) predict(mu fixedonly) post
	
		test [1._at] = [2._at]													// differences are not significant 
		test [3._at] = [4._at]
		test [5._at] = [6._at]
		test [7._at] = [8._at]
		
	marginsplot, title("Appendix Figure 1.3: Skin Color Ethnicity Interaction") ///
	xtitle("Standardized Skin Color") xlab(3 "Medium Light" 4 "Medium Dark" 5 "Dark" 6 "Very Dark") recast(scatter) plot1opts(msymbol("t")) ///
	plot2opts(msymbol("d")) name(margins_interaction, replace)
	

************ Appendix 1: Table 1.2- various skin color codings 

melogit votebuy i.color_category_region  wealth_quintile_richtopoor				/// 		//standardized color main model 
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)
	
	outreg2 using vbextracolorWP2019_jul3.doc, replace
	
melogit votebuy color_category_region wealth_quintile_richtopoor				///			 // standardized skin color continuous 
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

	outreg2 using vbextracolorWP2019_jul3.doc
	
melogit votebuy colorr wealth_quintile_richtopoor								///			// original lapop color measure 
partisan civic2 pol_interest participation_index i_trust 						///
voted registered ed female age urban colori 									///
if minority_country == 1 || country_round: , intpoints(10)

	outreg2 using vbextracolorWP2019_jul3.doc


************ Appendix 1: Figure 1.4- partisan id over group id 

preserve

rename country_1 Mexico
rename country_2 Guatemala
rename country_6 CostaRica
rename country_7 Panama
rename country_8 Colombia
rename country_9 Ecuador
rename country_10 Bolivia
rename country_11 Peru 
rename country_15 Brazil
rename country_16 Venezuela 
rename country_18 DR 

collapse partisan [pw=wt], by(pais etid)

foreach var in Mexico Guatemala CostaRica Panama Colombia Ecuador Bolivia Peru Brazil Venezuela DR { 
	graph twoway (bar partisan etid, barwidth(0.8) legend(label(1 "White") ///
	label(2 "Mestizo") label(3 "Indigenous") label(4 "Black") label(5 "Other"))) , name(partisan_`var', replace) ///
	title("`var'") graphregion(c(gs16) lcolor(black)) ytitle("% ID with a Political Party") xtitle("Ethno-Racial Self-Identification") ///
	xlab(1 "Wt" 2 "Mes" 3 "Ind" 4 "Blk" 5 "Otr")
}

graph combine partisan_Mexico partisan_Guatemala partisan_CostaRica partisan_Panama ///
partisan_Colombia partisan_Ecuador partisan_Bolivia partisan_Peru partisan_Brazil ///
partisan_Venezuela partisan_DR , title("Partisan ID by Country and Ethno-racial ID") ///
graphregion(c(gs16))

restore 	
	

**** Appendix 2 
**** Camp workers with original skin color levels 
preserve

use conjointanalysis.dta, clear 

gen lighttodark3 = .
	replace lighttodark3 = 1 if lighttodark == 1
	replace lighttodark3 = 2 if lighttodark >= 2 & lighttodark <= 5
	replace lighttodark3 = 3 if lighttodark == 6
	replace lighttodark3 = 4 if lighttodark >= 7 & lighttodark <=8
	replace lighttodark3 = 5 if lighttodark >= 9 & lighttodark <=10

reg vbprefer i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 & campaigner == 1  
coefplot, base levels(95) drop(_cons) xline(0) name(amce_task1_camp, replace) graphregion(c(gs16)) title("Vote buying" "Choice Task") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match") 

reg vb i.lighttodark3 i.newjob i.newvote i.party_match if task == 1 & campaigner == 1 
coefplot, base levels(95) drop(_cons) xline(0) name(vbamce_task1_camp, replace) graphregion(c(gs16)) title("Vote buying" "Rating Task") ///
coeflabels(1.lighttodark3 = "very light" 2.lighttodark3 = "light" 3.lighttodark3 = "medium" 4.lighttodark3 = "dark" 5.lighttodark3 = "very dark" ///
1.newjob = "cashier" 2.newjob = "teacher" 3.newjob = "lawyer" 1.newvote = "no vote" 2.newvote = "maybe vote" 3.newvote = "yes vote" ///
0.party_match = "no party match" 1.party_match = "party match") 

graph combine amce_task1_camp vbamce_task1_camp, name(campcombined, replace)

restore
